package com.ruoyi.evaluate.controller;

import java.util.List;
import java.util.Map;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.base.service.IBaseSemsterService;
import com.ruoyi.base.service.IBaseStudentService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.evaluate.domain.EvaluateScore;
import com.ruoyi.evaluate.service.IEvaluateScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价分数Controller
 * 
 * @author yepanpan
 * @date 2020-11-09
 */
@Api("评价分数信息管理")
@RestController
@RequestMapping("/evaluate/evalScore")
public class EvaluateScoreController extends BaseController
{
    @Autowired
    private IEvaluateScoreService evaluateScoreService;
    @Autowired
    private IBaseStudentService baseStudentService;
    @Autowired
    private IBaseSemsterService baseSemsterService;
    
    /**
     * 查询评价分数列表
     */
    @ApiOperation("获取评价分数列表")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvaluateScore evaluateScore)
    {
        startPage();
        List<EvaluateScore> list = evaluateScoreService.selectEvaluateScoreList(evaluateScore);
        return getDataTable(list);
    }
      
    /**
     * 查询教师评分信息
     */
    @ApiOperation("查询教师评分信息")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:score')")
    @GetMapping("/score")
    public TableDataInfo score(EvaluateScore evaluateScore)
    {    	
        List<EvaluateScore> list = evaluateScoreService.selectEvaluateScoreList(evaluateScore);
        return getDataTable(list);
    }

    /**
     * 导出评价分数列表
     */
    @ApiOperation("导出评价分数列表")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:export')")
    @Log(title = "评价分数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EvaluateScore evaluateScore)
    {
        List<EvaluateScore> list = evaluateScoreService.selectEvaluateScoreList(evaluateScore);
        ExcelUtil<EvaluateScore> util = new ExcelUtil<EvaluateScore>(EvaluateScore.class);
        return util.exportExcel(list, "evalScore");
    }

    /**
     * 获取评价分数详细信息
     */
    @ApiOperation("获取评价分数详细信息")
    @ApiImplicitParam(name = "id", value = "评价分数ID", required = true, dataType = "int", paramType = "path")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(evaluateScoreService.selectEvaluateScoreById(id));
    }


    /**
     * 保存评价分数
     */
    @ApiOperation("保存评价分数")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:add')")
    @Log(title = "评价分数", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody Map<String, Object> data)
    {
        return toAjax(evaluateScoreService.saveEvaluateScore(data));
    }
    
    /**
     * 新增评价分数
     */
    @ApiOperation("新增评价分数")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:add')")
    @Log(title = "评价分数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvaluateScore evaluateScore)
    {
        return toAjax(evaluateScoreService.insertEvaluateScore(evaluateScore));
    }

    /**
     * 修改评价分数
     */
    @ApiOperation("修改评价分数")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:edit')")
    @Log(title = "评价分数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvaluateScore evaluateScore)
    {
        return toAjax(evaluateScoreService.updateEvaluateScore(evaluateScore));
    }

    /**
     * 删除评价分数
     */
    @ApiOperation("删除评价分数")
    @ApiImplicitParam(name = "id", value = "评价分数ID", required = true, dataType = "int", paramType = "path")
    @PreAuthorize("@ss.hasPermi('evaluate:evalScore:remove')")
    @Log(title = "评价分数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(evaluateScoreService.deleteEvaluateScoreByIds(ids));
    }
}
